package com.bolt.common.db.converts;

/**
 * Created by Administrator on 2020/7/28.
 */
public class OracleJdbcTypeConvert implements IJdbcTypeConvert {

    /**
     * <p>
     * 执行类型转换
     * </p>
     *
     * @param fieldType 字段类型
     * @return
     */
    @Override
    public JavaType processTypeConvert(String fieldType) {
        String t = fieldType.toUpperCase();
        if (t.contains("CHAR")) {
            return JavaType.STRING;
        } else if (t.contains("DATE") || t.contains("TIMESTAMP")) {
            return JavaType.DATE;
        } else if (t.contains("NUMBER")) {
            if (t.matches("NUMBER\\(+\\d\\)")) {
                return JavaType.INTEGER;
            } else if (t.matches("NUMBER\\(+\\d{2}+\\)")) {
                return JavaType.LONG;
            }
            return JavaType.BIG_DECIMAL;
        } else if (t.contains("FLOAT")) {
            return JavaType.FLOAT;
        } else if (t.contains("clob")) {
            return JavaType.CLOB;
        } else if (t.contains("BLOB")) {
            return JavaType.OBJECT;
        } else if (t.contains("binary")) {
            return JavaType.BYTE_ARRAY;
        } else if (t.contains("RAW")) {
            return JavaType.BYTE_ARRAY;
        }
        return JavaType.STRING;
    }
}

 